var myMessages = ['info','warning','error','success'];

function hideAllMessages(){	 
    for (i=0; i<myMessages.length; i++){
        if($('.' + myMessages[i]).css('opacity')!=0){
            $('.' + myMessages[i]).fadeTo(0, 0);
        }
    }
}

function showMessage(type, head, content){
    hideAllMessages();
    $('#'+type+"_head").html(head);
    $('#'+type+"_content").html(content);    
    
    $('.'+type).fadeTo(100, 1);
}